package com.csweimei.rentmanagementtreasure.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.http.entity.HouseDetailHzBean;

public class RoomAdapter extends BaseQuickAdapter<HouseDetailHzBean.DataDTO.RoomlistDTO, BaseViewHolder> {
    public RoomAdapter() {
        super(R.layout.item_house_info_hz);
    }

    private int flag = 0;
    public void setSel(int index){
        flag = index;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, HouseDetailHzBean.DataDTO.RoomlistDTO roomlistDTO) {
            baseViewHolder.setText(R.id.room,roomlistDTO.getRoom());
            switch (roomlistDTO.getStatus()){
                case 0:
                    baseViewHolder.setText(R.id.state,"空置中");
                    break;
                case 1:
                    baseViewHolder.setText(R.id.state,"签约中");
                    break;
            }


            if (getItemPosition(roomlistDTO) == flag){
                baseViewHolder.setBackgroundResource(R.id.item,R.drawable.rect_main_8);
                baseViewHolder.setTextColorRes(R.id.room,R.color.white);
                baseViewHolder.setTextColorRes(R.id.state,R.color.white);
            }else {
                baseViewHolder.setTextColorRes(R.id.room,R.color.text_c);
                baseViewHolder.setTextColorRes(R.id.state,R.color.main_c);
                baseViewHolder.setBackgroundResource(R.id.item,R.drawable.rect_754_12_8);
            }
    }

}
